<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:SStuff.Pivot">


    <Style TargetType="local:PivotItemsControl">
        <Setter Property="Background" Value="Transparent" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PivotItemsControl">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <Grid>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition Height="*" />
                            </Grid.RowDefinitions>
                            
                            <ContentPresenter x:Name="PART_Container0" Grid.Row="1" ContentTemplate="{TemplateBinding ItemTemplate}" />
                            <ContentPresenter x:Name="PART_Container1" Grid.Row="1" ContentTemplate="{TemplateBinding ItemTemplate}" />
                            <StackPanel Orientation="Horizontal" Background="Transparent">
                                <Border Padding="40,0,0,0">
                                    <ItemsPresenter  HorizontalAlignment="Left" >
                                    </ItemsPresenter>
                                </Border>
                            </StackPanel>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="ItemsPanel">
            <Setter.Value>
                <ItemsPanelTemplate>
                    <StackPanel Orientation="Horizontal" >
                        <StackPanel.RenderTransform>
                            <TranslateTransform  />
                        </StackPanel.RenderTransform>
                    </StackPanel>
                </ItemsPanelTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style TargetType="local:PivotItem">
        <Setter Property="FontSize" Value="72" />
        <Setter Property="Margin" Value="35,0,0,35" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="local:PivotItem">
                    <Border Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualStateGroup.Transitions>
                                    <VisualTransition GeneratedDuration="0:0:0.200" />
                                </VisualStateGroup.Transitions>
                                <VisualState x:Name="Selected" >
                                    <Storyboard>
                                        <ColorAnimation Storyboard.TargetName="content" 
                                                        Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
                                                        To="#FFFFFFFF" />
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Unselected">
                                    <Storyboard >
                                        <ColorAnimation Storyboard.TargetName="content" 
                                                        Storyboard.TargetProperty="(Control.Foreground).(SolidColorBrush.Color)"
                                                        To="#FFAAAAAA" />
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <ContentControl x:Name="content" Foreground="#FFAAAAAA"  Content="{TemplateBinding Header}" ContentTemplate="{TemplateBinding HeaderTemplate}" />
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
